/**
 * 字体优化样式文件
 * @author Wu.Liang
 * @date 2025-01-30
 * @description 解决字体加载缓慢问题，优化用户体验
 */

// 字体预加载和优化
@font-face {
  font-family: 'iconfont';
  src: url('https://at.alicdn.com/t/font_2225171_8kdcwk4po24.ttf') format('truetype');
  font-display: swap; /* 优化字体显示策略 */
  font-weight: normal;
  font-style: normal;
}

// 备用字体栈 - 系统字体优先
$font-family-base: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;

// emoji字体栈 - 专门用于emoji显示
$emoji-font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Android Emoji", "EmojiSymbols", sans-serif;

// 图标字体类
.iconfont {
  font-family: 'iconfont', $font-family-base !important;
  font-style: normal;
  font-weight: normal;
  font-variant: normal;
  text-transform: none;
  line-height: 1;
  vertical-align: baseline;
  display: inline-block;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  
  // 字体加载失败时的备用样式
  &::before {
    font-family: 'iconfont', $font-family-base;
  }
}

// 字体加载优化类
.font-optimized {
  font-family: $font-family-base;
  font-display: swap;
  
  // 当iconfont加载完成时应用
  &.iconfont-loaded {
    .iconfont {
      font-family: 'iconfont', $font-family-base !important;
    }
  }
}

// 字体预加载提示
.font-loading {
  .iconfont {
    opacity: 0.7;
    transition: opacity 0.3s ease;
  }
  
  &.font-loaded {
    .iconfont {
      opacity: 1;
    }
  }
}

// 响应式字体大小
@media (max-width: 480px) {
  .iconfont {
    font-size: 14px;
  }
}

@media (min-width: 481px) and (max-width: 768px) {
  .iconfont {
    font-size: 16px;
  }
}

@media (min-width: 769px) {
  .iconfont {
    font-size: 18px;
  }
}